<?php
namespace Badmins\Controller;
use Think\Controller;
class ShopController extends Controller {
	public function index(){
		$listrow = (int)I('pageSize');
		if(empty($listrow)){
			$listrow = 15;
		}
		$where = array();
		$status = I('status/d');
		if($status){
			$map['close'] = $status;
		}
		$is_check = I('is_check');
		if($is_check!=null){
			$map['is_check'] = $is_check;
		}
		$name = I('name');
		if(!empty($name)){
			$where['username']  = array('like', "%{$name}%");
			$where['shop_name']  = array('like',"%{$name}%");
			$where['address']  = array('like',"%{$name}%");
			$where['_logic'] = 'or';
			$map['_complex'] = $where;
		}
		$p = I('pageCurrent/d')?I('pageCurrent/d'):'1';
		$db = M('shop');
		$count = $db->where($map)->count();
		$firstrow = ($p-1)*$listrow;
		$join = "";
		$field = "";
		$list = lists('shop',$join,$map,$field,"id desc",$firstrow,$listrow,2);
		if(!empty($list)){
			foreach ($list as $i=>$va){
				//审核人
				if($va['is_check'] == 1){
					$list[$i]['adminname'] = M('admin')->where("id='{$va['check_id']}'")->getField('username');
				}
				
				 
			}
		}
		if($count>$listrow){
			$show['total'] = $count;
			$show['listrow'] = $listrow;
			$this->assign('show',$show);
		}
		$this->assign('list',$list);
		$this->display();
	}
	/**
	 * 商家分类
	 */
	public function lev(){
		$listrow = (int)I('pageSize');
		if(empty($listrow)){
			$listrow = 15;
		}
		$p = I('pageCurrent/d')?I('pageCurrent/d'):'1';
		$count = M('ShopClassify')->count();
		$firstrow = ($p-1)*$listrow;
		$list = lists('ShopClassify','',1,"*","id desc",$firstrow,$listrow,2);
		if($count>$listrow){
			$show['total'] = $count;
			$show['listrow'] = $listrow;
			$this->assign('show',$show);
		}
		$this->assign('list',$list);
		$this->display();
	}
}